<%@ page import="com.cnplan.core.Constant" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/5/3
  Time: 9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!doctype html>
<html>

<%@include file="../../layout/css.jsp" %>

<body class="page-container-bg-solid">
<div class="page-wrapper">
    <div class="page-wrapper-row">
        <div class="page-wrapper-top">
            <div class="page-header">
                <%@include file="../../layout/nav-topmenu.jsp" %>
            </div>
        </div>
    </div>
    <div class="page-wrapper-row full-height">
        <div class="page-wrapper-middle">
            <div class="page-content">
                <div class="container-fluid">
                    <ul class="page-breadcrumb breadcrumb">
                        <li>
                            <span>&nbsp;&nbsp;</span>
                            <a href="${pageContext.request.contextPath}/">首页</a>
                            <i class="fa fa-chevron-right"></i>
                        </li>
                        <li>
                            <a href="${pageContext.request.contextPath}/auth/role/list">${title}列表</a>
                            <i class="fa fa-chevron-right"></i>
                        </li>
                        <li>
                            <span>编辑${title}</span>
                        </li>
                    </ul>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="portlet light">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class="icon-user font-green"></i>
                                        <span class="caption-subject bold font-green">编辑${title}</span>
                                    </div>
                                </div>
                                <div class="portlet-body form">
                                    <form id="my-form" class="form-horizontal" role="form"
                                          action="${pageContext.request.contextPath}/auth/role/update"
                                          method="post">
                                        <div class="form-body">
                                            <input type="hidden" id="id" name="id"
                                                   value="${record.id}"/>
                                            <div class="form-group">
                                                <label class="col-md-3 control-label">角色名称</label>
                                                <div class="col-md-9">
                                                    <input type="text"
                                                           value="${record.roleName}"
                                                           class="form-control input-inline input-large"
                                                           name="roleName"/>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-3 control-label">角色描述</label>
                                                <div class="col-md-9">
                                                    <input type="text" value="${record.roleDesc}"
                                                           class="form-control input-inline input-large"
                                                           name="roleDesc"/>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-3 control-label">显示顺序</label>
                                                <div class="col-md-9">
                                                    <input type="number"
                                                           value="${record.displayOrder}"
                                                           class="form-control input-inline input-large" min="1"
                                                           step="1"
                                                           name="displayOrder"/>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-md-3 control-label">是否激活</label>
                                                <div class="col-md-9">
                                                    <div class="radio-list"
                                                         style="margin-left: 20px;">
                                                        <label class="radio-inline">
                                                            <input type="radio"
                                                                   name="active"
                                                                   value="true"
                                                                   <c:if test="${record.active}">checked</c:if>>
                                                            是
                                                        </label>
                                                        <label class="radio-inline">
                                                            <input type="radio"
                                                                   name="active"
                                                                   value="false"
                                                                   <c:if test="${!record.active}">checked</c:if>>
                                                            否
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>

                                        <div class="form-actions">
                                            <div class="row">
                                                <div class="col-md-offset-3 col-md-9">
                                                    <button type="submit" class="btn green-meadow">提交</button>
                                                    <%
                                                        String fromUrl = request.getSession().getAttribute(Constant.FROM_URL) == null ? request.getHeader("Referer") : request.getSession().getAttribute(Constant.FROM_URL).toString();
                                                    %>
                                                    <a class="btn default" href="<%=fromUrl%>">返回</a>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="../../layout/footer.jsp" %>
</div>

<%@include file="../../layout/script.jsp" %>
<script>
    $(function () {
        $("#my-form").ajaxForm({
            dataType: 'json',
            success: function (data) {
                if (data['code'] === 200) {
                    window.location.href = "${pageContext.request.contextPath}/auth/role/list";
                } else {
                    toastr.error(data['message']);
                }
            }
        });
    });
</script>
</body>
</html>
